package com.huangmb.anymark.app.api.mock;

import android.support.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.huangmb.anymark.app.net.Response;
import com.huangmb.anymark.app.api.BaseApi;
import com.huangmb.anymark.app.model.Sex;
import com.huangmb.anymark.app.model.User;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/5/3 22:31
 */
public class UserApiMock {
    public static void login(String name, String password, BaseApi.Listener listener) {
        if("huangmb".equals(name) && "123456".equals(password)){
            User user = new User();
            user.setName(name);
            user.setPassword(password);
            user.setSex(Sex.MAN);
            String res = JSON.toJSONString(user);
            listener.onSuccess(res);
        }else {
            listener.onFail(1,"用户名或密码不正确");
        }
    }

    public static void logout(BaseApi.Listener listener) {
        Response response = new Response(0,"","success");
        listener.onRawData(JSON.toJSONString(response));
    }

    public static void register(@NonNull User user,BaseApi.Listener listener) {

    }
}